import { useState } from 'react';
import { useNavigate } from 'react-router-dom'
const ZingTable=(props:any)=>{
    const navigate = useNavigate();
    const initial=<tr><td>暂无数据</td><td>暂无数据</td><td>暂无数据</td><td>暂无数据</td></tr> 
    let [page,setpage]=useState(1)
    const noThing=()=>{
        console.log('暂无事件');
        
    }
    const operation1=(e:any)=>{
        if(props.operation1){
            props.operation1()
        }
    }
    const operation2=(e:any)=>{
        if(props.operation2){
            props.operation2()
        }
    }
    const operation3=(e:any)=>{
        if(props.operation3){
            props.operation3()
        }
    }
    const operation4=(e:any)=>{
        if(props.operation4){
            props.operation4()
        }
    }
    const toPrePage=(page:any)=>{
        console.log(23457689,props);

    }
    return (
        <div>
        <table style={{textAlign:'center',fontSize:10,backgroundColor:'white',width:props.Tstyle.width?props.Tstyle.width:300}}>
            <tr style={{borderBottom:'1px solid rgb(228, 224, 224)',backgroundColor:props.Tstyle.hbackgroundColor?props.Tstyle.hbackgroundColor:'white'}}>
                {props.theads.map((v:any)=><th style={{width:100,height:30,lineHeight:5}} key={v.key}>{v.name}</th>)}
            </tr>
            <tbody>
                {props.tbodys.id?props.tbodys.content.map((v:any,i:number)=><tr key={i}>{props.theads.map((j:any,l:number)=>j.key=='operate'?
                <td style={{height:30,lineHeight:props.Tstyle.lineHeight?props.Tstyle.lineHeight:5}} key={l}>
                    <span style={{color:'blue',cursor:'pointer'}} onClick={operation1}>{v[j.key][0]?v[j.key][0]:''}</span>
                    <span style={{color:'blue',cursor:'pointer'}} onClick={operation2}>{v[j.key][1]?v[j.key][1]:''}</span>
                    <span style={{color:'blue',cursor:'pointer'}} onClick={operation3}>{v[j.key][2]?v[j.key][2]:''}</span>
                    <span style={{color:'blue',cursor:'pointer'}} onClick={operation4}>{v[j.key][3]?v[j.key][3]:''}</span>
                    </td> : <td style={{height:30,lineHeight:5}} key={l}>{v[j.key]}</td>)}</tr>):initial}
            </tbody>
        </table>
        <div  style={{fontSize:20,display:props.Tstyle.Pdisplay || 'none'}}><span style={{cursor:'pointer'}} onClick={toPrePage}>{'<'}</span><span style={{backgroundColor:'green',paddingLeft:10,paddingRight:10,paddingTop:5,paddingBottom:5,borderRadius:5}}>1</span><span>2</span><span style={{cursor:'pointer'}}>{'>'}</span></div>
        </div>
    )
}
export default ZingTable